#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020/8/9 10:38|10:38
# @Author  : yangdingyi
# @File    : 2020-08-09.1.5483.整理字符串
# @Software: PyCharm
from tools.my_methods import *


class Solution:
    def makeGood(self, s: str) -> str:
        ans = ''
        ls = len(s)
        ss = s

        def is_same(s1, s2):
            c1 = ord(s1) - ord('a')
            c2 = ord(s2) - ord('A')
            return c1 == c2
        for j in range(ls):
            lss = len(ss)
            si = [True for i in range(lss)]
            p = True
            for i in range(lss):
                if si[i] and i < lss - 1:
                    if is_same(ss[i], ss[i + 1]) or is_same(ss[i + 1], ss[i]):
                        si[i] = False
                        si[i + 1] = False
                        p = False
            if p:
                break
            sss = ''
            for i in range(lss):
                if si[i]:
                    sss += ss[i]
            ss = sss

        ans = ss
        return ans


questions = [
    ('aabb',),
    ('saf',),
    ('leEeetcode',),
    ('abBAcC',),
]

work(questions, lambda q: Solution().makeGood(q[0]))
